<template>
	<view :style="[{animation: 'show ' + ((1+1)*0.2+1) + 's 1'}]">
		<cu-custom bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">{{title}}</block>
		</cu-custom>
		<view class="cu-card case no-card">
			<view class="cu-item shadow">
				<view class="cu-list menu-avatar">
					<view class="cu-item">
						<view class="cu-avatar round lg" :style="[{backgroundImage:'url('+href+'/image/icon.png)'}]"></view>
						<view class="content flex-sub">
							<view class="text-grey">{{name}}</view>
							<view class="text-gray text-sm flex justify-between">
								{{list.timer}}
								<view class="text-gray text-sm">
									<text class="cuIcon-attentionfill margin-lr-xs"></text> {{list.look_num}}
									<!-- <text class="cuIcon-appreciatefill margin-lr-xs"></text> 99+
										<text class="cuIcon-messagefill margin-lr-xs"></text> (()) -->
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="cont">
			<u-parse :content="article" />
		</view>
	</view>
</template>

<script>
	import uParse from '@/components/gaoyia-parse/parse.vue'
	export default {
		components: {
			uParse
		},
		data() {
			return {
				title: "数据加载中...",
				article: "<p>数据加载中...</p>",
				list: "",
				id: "",
				name: "",
				href: ""
			}
		},
		methods: {
			ajax(id) {
				var _this = this;
				uni.showLoading({
					title: '加载中'
				});
				uni.request({
					url: this.$api + 'index.php',
					method: "POST",
					data: JSON.stringify({
						id: 201,
						ids: id
					}),
					header: {
						'content-type': 'application/json'
					},
					success: (res) => {
						uni.hideLoading();
						console.log(res.data);

						if (res.data.code == "200") {
							_this.title = res.data.data[0].title;
							_this.article = res.data.data[0].cont;
							_this.list = res.data.data[0];
						} else {
							uni.showToast({
								title: '获取失败~',
								icon: "none",
								duration: 2000
							});
						};
					}
				});
			}
		},
		onLoad: function(option) {
			console.log(option.id);
			this.ajax(option.id);
			this.id = option.id;
			this.name = this.$name;
			this.href = this.$href;

			uni.request({
				url: this.$api+'index.php',
				method: "POST",
				data: JSON.stringify({
					id: 202,
					ids: option.id
				}),
				header: {
					'content-type': 'application/json'
				},
				success: (res) => {
					console.log(res);
				}
			});
		},
		onShareAppMessage(res) {
			return {
				title: this.list.title,
				path: '/' + this.$mp.page.route + "?id=" + this.id
			}
		}
	}
</script>

<style>
	.cont {
		font-size: 32upx;
		padding: 20upx;
		box-sizing: border-box;
	}

	.wxParse .code {
		width: 100%;
		height: auto;
		word-wrap: break-word;
		word-break: break-all;
		overflow: hidden;
	}
</style>
